<?php

    require_once '../Model/Address.php';
    require_once '../Model/FullName.php';
    require_once '../Model/CreditCard.php';
    require_once '../Model/Customer.php';
    require_once '../View/GuestView.php';

    $username = $_POST['username'];
    $password = hash("md5", $_POST['password']);
    $fullname = new FullName(NULL, $_POST['fname'], $_POST['lname'], $_POST['mname']);
    $email = $_POST['email'];
    $baddress = new Address(NULL, $_POST['bhouse'], $_POST['bstreet'], $_POST['bsubdivision'], $_POST['bcity'], $_POST['bpostalcode'], $_POST['bcountry']);
    $daddress = new Address(NULL, $_POST['dhouse'], $_POST['dstreet'], $_POST['dsubdivision'], $_POST['dcity'], $_POST['dpostalcode'], $_POST['dcountry']);
    $ccfullname = new FullName(NULL, $_POST['ccfname'], $_POST['cclname'], $_POST['ccmname']);
    $cardexpirydate = DateTime::createFromFormat("m-d-Y" ,$_POST['creditcardmonth']."-01-".$_POST['creditcardyear']);
    $creditcard = new CreditCard($ccfullname, $_POST['cardnumber'], $_POST['cardtype'], $cardexpirydate);

    $customer = new Customer($username, $password, $fullname, $email, $baddress, $daddress, $creditcard, FALSE);

    $customerid = Customer::InsertCustomer($customer);

    if($customerid != NULL) {
        GuestView::RegisterSuccess($customer);
    }
    else {

    }

?>
